package self.niu.com.resume.db.dao.impl;

import com.lidroid.xutils.DbUtils;
import com.lidroid.xutils.exception.DbException;

import java.util.List;

import self.niu.com.resume.AppBase;
import self.niu.com.resume.db.KnowAbility;
import self.niu.com.resume.db.Projects;
import self.niu.com.resume.db.dao.ProjectsDao;

/**
 * Created by Administrator on 2015/9/28 0028.
 */
public class ProjectDaoImpl implements ProjectsDao {
    private DbUtils db;

    public ProjectDaoImpl() {
        this.db = AppBase.db;
    }

    @Override
    public void update(Projects pro, String numberCusor) {
        try {
            db.update(pro, numberCusor);
        } catch (DbException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void save(Projects pro) {
        try {
            db.save(pro);
        } catch (DbException e) {
            e.printStackTrace();
        }
    }

    @Override
    public void deleteById(int id) {

    }

    @Override
    public Projects find(String name) {
        return null;
    }

    @Override
    public List<Projects> findAll() {
        List<Projects> know = null;
        try {
            know = db.findAll(Projects.class);
        } catch (DbException e) {
            e.printStackTrace();
        }
        return know;
    }

    @Override
    public void createDb(Class t) {
        try {
            db.createTableIfNotExist(t);
        } catch (DbException e) {
            e.printStackTrace();
        }
    }
}
